<?php
//  +----------------------------------------------------------------------
//  | Copyright (c) 2015-2025 http://www.hdphp.cn All rights reserved.
//  | Licensed ( http://www.hdphp.cn/licenses/ )
//  | Author: Jack <sophia2152@qq.com>
//  | 官方网址: http://www.hdphp.cn
//  | 这不是一个自由软件！您只能在不用于商业目的的前提下对程序代码进行修改和使用。
//  | 任何企业和个人不允许对程序代码以任何形式任何目的再发布。
//  +----------------------------------------------------------------------

use think\facade\Route;
use think\facade\Config;
use think\Response;

/**
 * 后台管理路由配置
 */
Route::group('adminapi', function () {

    /**
     * 无需授权的接口
     */
    Route::group(function () {
        // 测试地址
        Route::get('index', 'Test/index')->option(['real_name' => '测试地址']);
        // 用户名密码登录
        Route::post('login', 'Login/login')->name('AdminLogin')->option(['real_name' => '用户名密码登录']);
        // 短信登录
        Route::post('mobile_login', 'Login/mobileLogin')->name('mobileLogin')->option(['real_name' => '短信登录']);
        // 短信重置密码
        Route::post('reset_pwd', 'Login/resetPwd')->name('resetPwd')->option(['real_name' => '短信重置密码']);
        // 下载文件
        Route::get('download', 'PublicController/download')->option(['real_name' => '下载文件']);
        // 验证码
        Route::get('identifying_code', 'PublicController/identifyingCode')->name('identifyingCode')->option(['real_name' => '获取验证码']);
        // 获取版权
        Route::get('copyright', 'Common/getCopyright')->option(['real_name' => '获取版权']);
        // 扫码上传
        Route::post('file/scan/upload', 'PublicController/scanUpload')->name('scanUpload')->option(['real_name' => '扫码上传']);
    });

    /**
     * 公共相关路由
     */
    Route::group(function () {


    })->middleware([
        \app\http\middleware\admin\AdminAuthTokenMiddleware::class,
        \app\http\middleware\admin\AdminCkeckRoleMiddleware::class,
        \app\http\middleware\admin\AdminLogMiddleware::class
    ]);


    /**
     * 系统设置维护 系统权限管理、系统菜单管理 系统配置 相关路由
     */
    Route::group('setting', function () {
        /* 角色管理 */

        // 角色列表
        Route::get('role/list', 'v1.system.SystemRole/index')->option(['real_name' => '角色列表']);
        // 角色缓存列表
        Route::get('role/cache_roles', 'v1.system.SystemRole/get_cache_roles')->option(['real_name' => '角色列表']);
        // 角色权限列表
        Route::get('role/role_menus', 'v1.system.SystemRole/role_menus')->option(['real_name' => '角色权限列表']);
        // 角色详情
        Route::get('role/read/:id', 'v1.system.SystemRole/read')->option(['real_name' => '角色详情']);
        // 创建角色
        Route::post('role/create', 'v1.system.SystemRole/save')->option(['real_name' => '创建角色']);
        // 修改角色
        Route::put('role/update/:id', 'v1.system.SystemRole/update')->option(['real_name' => '修改角色']);
        // 修改角色状态
        Route::put('role/set_status/:id/:status', 'v1.system.SystemRole/set_status')->option(['real_name' => '修改角色状态']);
        // 删除角色
        Route::delete('role/delete/:id', 'v1.system.SystemRole/delete')->option(['real_name' => '删除角色']);
        // 角色列表搜索条件
        Route::get('role/search_roles', 'v1.system.SystemRole/select_list')->option(['real_name' => '角色列表搜索条件']);

        /* 管理员 */

        // 退出登陆
        Route::get('admin/logout', 'v1.system.admin.SystemAdmin/logout')->name('SystemAdminLogout')->option(['real_name' => '退出登陆']);
        // 管理员列表
        Route::get('admin/list', 'v1.system.admin.SystemAdmin/index')->name('SystemAdminIndex')->option(['real_name' => '管理员列表']);
        // 创建管理员
        Route::post('admin/create', 'v1.system.admin.SystemAdmin/add')->name('SystemAdminCreate')->option(['real_name' => '创建管理员']);
        // 获取详情
        Route::get('admin/read/:id', 'v1.system.admin.SystemAdmin/read')->name('SystemAdminRead')->option(['real_name' => '管理员详情']);
        // 修改管理员
        Route::put('admin/update/:id', 'v1.system.admin.SystemAdmin/edit')->name('SystemAdminUpdate')->option(['real_name' => '修改管理员']);
        // 修改状态
        Route::put('admin/set_status/:id/:status', 'v1.system.admin.SystemAdmin/set_status')->name('SystemAdminSetStatus')->option(['real_name' => '修改管理员状态']);
        // 删除管理员
        Route::delete('admin/delete/:id', 'v1.system.admin.SystemAdmin/delete')->name('SystemAdminDelete')->option(['real_name' => '删除管理员']);
        // 获取当前管理员信息
        Route::get('admin/info', 'v1.system.admin.SystemAdmin/info')->name('SystemAdminInfo')->option(['real_name' => '获取当前管理员信息']);
        // 修改当前管理员信息
        Route::put('admin/update_admin', 'v1.system.admin.SystemAdmin/update_admin')->name('SystemAdminUpdateAdmin')->option(['real_name' => '修改当前管理员信息']);
        // 获取权限列表
        Route::get('admin/menus', 'v1.system.admin.SystemAdmin/get_menus')->option(['real_name' => '获取权限列表']);


        /* 权限菜单 */

        // 菜单列表
        Route::get('menus/list', 'v1.system.SystemMenus/index')->option(['real_name' => '菜单列表']);
        // 获取菜单权限和权限标识
        Route::get('menus/unique', 'v1.system.SystemMenus/unique')->name('SystemMenusUnique')->option(['real_name' => '获取菜单权限和权限标识']);
        // 菜单详情
        Route::get('menus/read/:id', 'v1.system.SystemMenus/read')->name('SystemMenusRead')->option(['real_name' => '菜单详情']);
        // 创建菜单
        Route::post('menus/create', 'v1.system.SystemMenus/save')->name('SystemMenusCreate')->option(['real_name' => '创建菜单']);
        // 修改菜单
        Route::put('menus/update/:id', 'v1.system.SystemMenus/update')->name('SystemMenusUpdate')->option(['real_name' => '修改菜单']);
        // 修改显示
        Route::put('menus/set_show/:id/:is_show', 'v1.system.SystemMenus/set_show')->name('SystemMenusShow')->option(['real_name' => '修改菜单状态']);
        // 删除菜单
        Route::delete('menus/delete/:id', 'v1.system.SystemMenus/delete')->name('SystemMenusDelete')->option(['real_name' => '删除菜单']);


        /* 部门管理 */

        // 部门列表
        Route::get('dept/list', 'v1.system.SystemDepartment/index')->option(['real_name' => '部门列表']);
        // 部门详情
        Route::get('dept/read/:id', 'v1.system.SystemDepartment/read')->name('SystemDeptRead')->option(['real_name' => '部门详情']);
        // 创建部门
        Route::post('dept/create', 'v1.system.SystemDepartment/save')->name('SystemDeptCreate')->option(['real_name' => '创建部门']);
        // 修改部门
        Route::put('dept/update/:id', 'v1.system.SystemDepartment/update')->name('SystemDeptUpdate')->option(['real_name' => '修改部门']);
        // 修改显示
        Route::put('dept/set_status/:id/:status', 'v1.system.SystemDepartment/set_status')->name('SystemDeptShow')->option(['real_name' => '修改部门状态']);
        // 删除部门
        Route::delete('dept/delete/:id', 'v1.system.SystemDepartment/delete')->name('SystemDeptDelete')->option(['real_name' => '删除部门']);


        /* 系统配置 */

        // 配置分类列表
        Route::get('config_cat/list', 'v1.system.config.SystemConfigTab/index')->option(['real_name' => '获取配置分类列表']);
        // 获取配置分类下拉树
        Route::get('config_cat/select_list', 'v1.system.config.SystemConfigTab/select_list')->option(['real_name' => '获取配置分类下拉树']);
        // 创建配置分类
        Route::post('config_cat/create', 'v1.system.config.SystemConfigTab/create')->name('SystemConfigTabCreate')->option(['real_name' => '创建配置分类']);
        // 修改配置分类
        Route::put('config_cat/update/:id', 'v1.system.config.SystemConfigTab/update')->name('SystemConfigTabUpdate')->option(['real_name' => '修改配置分类']);
        // 修改配置分类状态
        Route::put('config_cat/set_status/:id/:status', 'v1.system.config.SystemConfigTab/set_status')->option(['real_name' => '修改配置分类状态']);
        // 删除配置分类
        Route::delete('config_cat/delete/:id', 'v1.system.config.SystemConfigTab/delete')->name('SystemConfigTabDelete')->option(['real_name' => '删除配置分类']);

        // 配置列表
        Route::get('config/list', 'v1.system.config.SystemConfig/index')->option(['real_name' => '获取配置列表']);
        // 创建配置
        Route::post('config/create', 'v1.system.config.SystemConfig/create')->name('SystemConfigCreate')->option(['real_name' => '创建配置']);
        // 修改配置
        Route::put('config/update/:id', 'v1.system.config.SystemConfig/update')->name('SystemConfigUpdate')->option(['real_name' => '修改配置']);
        // 删除配置
        Route::delete('config/delete/:id', 'v1.system.config.SystemConfig/delete')->name('SystemConfigDelete')->option(['real_name' => '删除配置']);
        // 修改配置状态
        Route::put('config/set_status/:id/:status', 'v1.system.config.SystemConfig/set_status')->option(['real_name' => '修改配置状态']);
        // 获取单个配置值
        Route::get('config/get_system/:name', 'v1.system.config.SystemConfig/get_system')->option(['real_name' => '获取单个配置值']);
        // 获取某个分类下的所有配置信息
        Route::get('config_list/:tabId', 'v1.system.config.SystemConfig/get_config_list')->option(['real_name' => '获取某个分类下的所有配置信息']);
        // 基本配置保存数据
        Route::post('config/save_basics', 'v1.system.config.SystemConfig/save_basics')->option(['real_name' => '基本配置保存数据']);
        // 获取置缩略图配置信息
        Route::get('config/image', 'v1.system.config.SystemConfig/getImageConfig')->option(['real_name' => '获取置缩略图配置信息']);


        /* 云存储配置 */

        // 选择存储方式
        Route::get('config/storage/save_type/:type', 'v1.system.config.SystemStorage/uploadType')->name('SystemStorageUploadType')->option(['real_name' => '选择存储方式']);
        // 云存储列表
        Route::get('config/storage', 'v1.system.config.SystemStorage/index')->name('SystemStorageIndex')->option(['real_name' => '云存储列表']);
        // 获取配置信息
        Route::get('config/storage/config_form/:type', 'v1.system.config.SystemStorage/getConfigForm')->name('getConfigForm')->option(['real_name' => '获取云存储配置表单']);
        // 获取配置类型
        Route::get('config/storage/config', 'v1.system.config.SystemStorage/getConfig')->name('SystemStorageConfig')->option(['real_name' => '获取配置类型']);
        // 保存云存储配置
        Route::post('config/storage/config', 'v1.system.config.SystemStorage/saveConfig')->name('SystemStorageSaveConfig')->option(['real_name' => '保存云存储配置']);
        // 获取空间区域下拉数据
        Route::get('config/storage/select_list/:type', 'v1.system.config.SystemStorage/getSelectList')->name('SystemStorageCreate')->option(['real_name' => '获取空间区域下拉数据']);
        // 同步云存储列表
        Route::put('config/storage/syncs/:type', 'v1.system.config.SystemStorage/syncs')->name('SystemStorageSynch')->option(['real_name' => '同步云存储列表']);
        // 创建云存储数据
        Route::post('config/storage/create/:type', 'v1.system.config.SystemStorage/save')->name('SystemStorageSave')->option(['real_name' => '创建云存储数据']);
        // 修改云存储状态
        Route::put('config/storage/status/:id', 'v1.system.config.SystemStorage/status')->name('SystemStorageStatus')->option(['real_name' => '修改云存储状态']);
        // 获取修改云存储域名
        Route::get('config/storage/domain/:id', 'v1.system.config.SystemStorage/getUpdateDomain')->name('getUpdateDomain')->option(['real_name' => '获取修改云存储域名表单']);
        // 修改云存储域名
        Route::post('config/storage/domain/:id', 'v1.system.config.SystemStorage/updateDomain')->name('updateDomain')->option(['real_name' => '修改云存储域名']);
        // 删除云存储
        Route::delete('config/storage/delete/:id', 'v1.system.config.SystemStorage/delete')->name('SystemStorageDelete')->option(['real_name' => '删除云存储']);


        /* 系统通知配置 */

        // 系统通知列表
        Route::get('notification/index', 'v1.message.SystemNotification/index')->option(['real_name' => '系统通知列表']);
        // 获取单条数据
        Route::get('notification/info', 'v1.message.SystemNotification/info')->option(['real_name' => '获取单条通知数据']);
        // 保存通知设置
        Route::post('notification/save', 'v1.message.SystemNotification/save')->option(['real_name' => '保存通知设置']);
        // 修改消息状态
        Route::put('notification/set_status/:type/:status/:id', 'v1.message.SystemNotification/set_status')->option(['real_name' => '修改消息状态']);

    })->middleware([
        \app\http\middleware\admin\AdminAuthTokenMiddleware::class,
        \app\http\middleware\admin\AdminCkeckRoleMiddleware::class,
        \app\http\middleware\admin\AdminLogMiddleware::class
    ]);


    /**
     * 维护 相关路由
     */
    Route::group('system', function () {

    })->middleware([
        \app\http\middleware\admin\AdminAuthTokenMiddleware::class,
        \app\http\middleware\admin\AdminCkeckRoleMiddleware::class,
        \app\http\middleware\admin\AdminLogMiddleware::class
    ]);

    /**
     * 附件相关路由
     */
    Route::group('file', function () {
        // 附件分类列表
        Route::get('category/list', 'v1.system.attachment.SystemAttachmentCategory/index')->option(['real_name' => '获取附件分类列表']);
        // 创建附件分类
        Route::post('category/create', 'v1.system.attachment.SystemAttachmentCategory/create')->name('SystemFileCategoryCreate')->option(['real_name' => '创建附件分类']);
        // 修改附件分类
        Route::put('category/update/:id', 'v1.system.attachment.SystemAttachmentCategory/update')->name('SystemFileCategoryUpdate')->option(['real_name' => '修改附件分类']);
        // 删除附件分类
        Route::delete('category/delete/:id', 'v1.system.attachment.SystemAttachmentCategory/delete')->name('SystemFileCategoryDelete')->option(['real_name' => '删除附件分类']);

        // 图片附件列表
        Route::get('list', 'v1.system.attachment.SystemAttachment/index')->option(['real_name' => '图片附件列表']);
        // 删除图片
        Route::post('file/delete', 'v1.system.attachment.SystemAttachment/delete')->option(['real_name' => '删除图片']);
        // 移动图片分类
        Route::put('file/do_move', 'v1.system.attachment.SystemAttachment/moveImageCate')->option(['real_name' => '移动图片分类']);
        // 修改图片名称
        Route::put('file/update/:id', 'v1.system.attachment.SystemAttachment/update')->option(['real_name' => '修改图片名称']);
        // 上传图片
        Route::post('upload/[:upload_type]', 'v1.system.attachment.SystemAttachment/upload')->option(['real_name' => '上传图片']);
        // 获取上传类型
        Route::get('upload_type', 'v1.system.attachment.SystemAttachment/uploadType')->option(['real_name' => '上传类型']);
        // 分片上传本地视频
        Route::post('video_upload', 'v1.system.attachment.SystemAttachment/videoUpload')->option(['real_name' => '分片上传本地视频']);
        // oss视频素材保存
        Route::post('video_attachment', 'v1.system.attachment.SystemAttachment/saveVideoAttachment')->option(['real_name' => '视频素材保存']);

        // 获取扫码上传页面链接以及参数
        Route::get('scan/qrcode', 'v1.system.attachment.SystemAttachment/scanUploadQrcode')->option(['real_name' => '获取扫码上传页面链接以及参数']);
        // 删除二维码
        Route::get('remove/qrcode', 'v1.system.attachment.SystemAttachment/removeUploadQrcode')->option(['real_name' => '删除二维码']);
        // 获取扫码上传的图片数据
        Route::get('scan/image/list/:scan_token', 'v1.system.attachment.SystemAttachment/scanUploadImage')->option(['real_name' => '获取扫码上传的图片数据']);
        // 网络图片上传
        Route::post('online/upload', 'v1.system.attachment.SystemAttachment/onlineUpload')->option(['real_name' => '网络图片上传']);
        // 获取上传信息
        Route::get('get/way_data', 'v1.system.attachment.SystemAttachment/getAdminsData')->option(['real_name' => '获取上传信息']);
        // 保存上传信息
        Route::get('set/way_data/:is_way', 'v1.system.attachment.SystemAttachment/setAdminsData')->option(['real_name' => '保存上传信息']);

    })->middleware([
        \app\http\middleware\admin\AdminAuthTokenMiddleware::class,
        \app\http\middleware\admin\AdminCkeckRoleMiddleware::class,
        \app\http\middleware\admin\AdminLogMiddleware::class
    ]);

    /**
     * 用户模块 相关路由
     */
    Route::group('user', function () {

    })->middleware([
        \app\http\middleware\admin\AdminAuthTokenMiddleware::class,
        \app\http\middleware\admin\AdminCkeckRoleMiddleware::class,
        \app\http\middleware\admin\AdminLogMiddleware::class
    ]);

    /**
     * 系统日志 相关路由
     */
    Route::group('log', function () {
        // 系统日志
        Route::get('syslog', 'v1.system.log.SystemLog/index')->name('SystemLog')->option(['real_name' => '系统日志']);
        // 系统登录日志
        Route::get('login', 'v1.system.log.SystemLoginLog/index')->name('SystemLoginLog')->option(['real_name' => '系统登录日志']);
        // 系统日志管理员搜索条件
        Route::get('search_admin', 'v1.system.log.SystemLog/search_admin')->option(['real_name' => '系统日志管理员搜索条件']);

    })->middleware([
        \app\http\middleware\admin\AdminAuthTokenMiddleware::class,
        \app\http\middleware\admin\AdminCkeckRoleMiddleware::class,
        \app\http\middleware\admin\AdminLogMiddleware::class
    ]);

    /**
     * miss 路由
     */
    Route::miss(function () {
        if (app()->request->isOptions()) {
            $header = Config::get('cookie.header');
            $header['Access-Control-Allow-Origin'] = app()->request->header('origin');
            return Response::create('ok')->code(200)->header($header);
        }
        return Response::create()->code(404);
    });

})->prefix('admin.')->middleware(\app\http\middleware\AllowOriginMiddleware::class);;